import BaseModel from './.model';
import { Table, Column, DataType, ForeignKey } from 'sequelize-typescript';
import OrderModel from './order.model';
import ProductModel from './product.model';

@Table({ tableName: 'order_items' })
export default class OrderItemModel extends BaseModel {
  /** 订单ID */
  @ForeignKey(() => OrderModel)
  @Column({ type: DataType.UUID, comment: '订单ID' })
  orderId!: string;

  /** 产品ID */
  @ForeignKey(() => ProductModel)
  @Column({ type: DataType.UUID, comment: '产品ID' })
  productId!: string;

  /** 购买数量 */
  @Column({ type: DataType.INTEGER, comment: '购买数量' })
  quantity!: number;

  /** 购买时的单价 */
  @Column({ type: DataType.FLOAT, comment: '购买时的单价' })
  price!: number;
}
